<?php
class Home_Controller extends Template_Controller {

	public $template = 'client/index';
	public $language = 'client/index';
	
    public function __construct()
    {
        parent::__construct();
        
        //Css
        $this->template->css = $this->site['theme_url'].'home/home.css';
        //View
        //$this->get_view();
		$this->language = $this->get_client_lang();
    }
    
    public function index()
    {	
        $this->programs();
		$this->news();
		$this->videos();
		$this->knowledge();
    }
	 public function event($m,$y)
    {	
        $this->template->content = new View('home/index');
		$this->programs();
		$this->news();
		$this->videos();
		$this->knowledge();
		$this->template->content->prm=$y;
		$this->template->content->chm=$m;
    }
	public function programs()
    {
	 	$this->template->content = new View('home/index');
		$this->db->select('*');
		$this->db->from('programs');
		$this->db->join('programs_content', 'programs_content.programs_id', 'programs.programs_id');
		$this->db->where('programs_content.languages_id',$this->language);
		$this->db->where('programs_status','1');
		$this->db->orderby('programs.programs_sort_order','desc');
		$this->db->orderby('programs.programs_id','desc');
		$this->db->limit(2,0);
		$query = $this->db->get();
		$mListPrograms = $query->result_array(false);
		$this->template->content->mListPrograms = $mListPrograms;
	}
	public function news()
    {
	 	$this->db->select('*');
		$this->db->from('news');
		$this->db->join('news_content', 'news_content.news_id', 'news.news_id');
		$this->db->where('news_content.languages_id',$this->language);
		$this->db->where('news_status','1');
		$this->db->orderby('news.news_sort_order','desc');
		$this->db->orderby('news.news_id','desc');
		$this->db->limit(4,0);
		$query = $this->db->get();
		$mListNews = $query->result_array(false);
		$this->template->content->mListNews = $mListNews;
	}
	public function knowledge()
    {
	 	$this->db->select('*');
		$this->db->from('knowledges');
		$this->db->join('knowledges_content', 'knowledges_content.knowledges_id', 'knowledges.knowledges_id');
		$this->db->where('knowledges_content.languages_id',$this->language);
		$this->db->where('knowledges_status','1');
		$this->db->orderby('knowledges.knowledges_sort_order','desc');
		$this->db->orderby('knowledges.knowledges_id','desc');
		$this->db->limit(1,0);
		$query = $this->db->get();
		$mListKnowledge = $query->result_array(false);
		$this->template->content->mListKnowledge = $mListKnowledge[0];
	}
	public function videos()
    {
	 	$this->db->select('*');
		$this->db->from('videos');
		$this->db->join('videos_content', 'videos_content.videos_id', 'videos.videos_id');
		$this->db->where('videos_content.languages_id',$this->language);
		$this->db->where('videos_status','1');
		$this->db->orderby('videos.videos_sort_order','desc');
		$this->db->orderby('videos.videos_id','desc');
		$this->db->limit(4,0);
		$query = $this->db->get();
		$mListVideos = $query->result_array(false);
		$this->template->content->mListVideos = $mListVideos;
	}
}
?>